import { S } from '../../s';
import { IPSAppCounterRef } from '../../app/control/ipsapp-counter-ref';
import { PSMDAjaxControlContainerImpl } from '../psmdajax-control-container-impl';
import { IPSDETree } from './ipsdetree';
import { IPSDETreeColumn } from './ipsdetree-column';
import { IPSDETreeNode } from './ipsdetree-node';
import { IPSDETreeNodeRS } from './ipsdetree-node-rs';
import { IPSLanguageRes } from '../../res/ipslanguage-res';

export class PSDETreeImpl
  extends PSMDAjaxControlContainerImpl
  implements IPSDETree
{
  get codeName(): string {
    return this.M.codeName;
  }

  get emptyText(): string {
    return this.M.emptyText;
  }

  protected emptytextpslanguageres: IPSLanguageRes;
  getEmptyTextPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.emptytextpslanguageres ||
      (this.emptytextpslanguageres = this.fillObjectModel(
        S._276,
        this.M.getEmptyTextPSLanguageRes,
        S._2b4,
      ) as IPSLanguageRes)
    );
  }

  protected psappcounterref: IPSAppCounterRef;
  getPSAppCounterRef(): IPSAppCounterRef | null {
    if (this.psappcounterref != null) return this.psappcounterref;
    const value = this.M.getPSAppCounterRef;
    if (value == null) {
      return;
    }
    this.psappcounterref = this.findPSAppCounterRef(value);
    return this.psappcounterref;
  }

  protected psdetreecolumns: IPSDETreeColumn[];
  getPSDETreeColumns(): IPSDETreeColumn[] | null {
    return (
      this.psdetreecolumns ||
      (this.psdetreecolumns = this.fillChildListModel(
        this.M.getPSDETreeColumns,
        S._1af,
      ) as IPSDETreeColumn[])
    );
  }

  findPSDETreeColumn(objKey: any): IPSDETreeColumn | null {
    return this.getPSModel5(
      S._1af,
      this.getPSDETreeColumns(),
      objKey,
    ) as IPSDETreeColumn;
  }

  protected psdetreenoderss: IPSDETreeNodeRS[];
  getPSDETreeNodeRSs(): IPSDETreeNodeRS[] | null {
    return (
      this.psdetreenoderss ||
      (this.psdetreenoderss = this.fillChildListModel(
        this.M.getPSDETreeNodeRSs,
        S._1b5,
      ) as IPSDETreeNodeRS[])
    );
  }

  findPSDETreeNodeRS(objKey: any): IPSDETreeNodeRS | null {
    return this.getPSModel5(
      S._1b5,
      this.getPSDETreeNodeRSs(),
      objKey,
    ) as IPSDETreeNodeRS;
  }

  protected psdetreenodes: IPSDETreeNode[];
  getPSDETreeNodes(): IPSDETreeNode[] | null {
    return (
      this.psdetreenodes ||
      (this.psdetreenodes = this.fillChildListModel(
        this.M.getPSDETreeNodes,
        S._1b2,
      ) as IPSDETreeNode[])
    );
  }

  findPSDETreeNode(objKey: any): IPSDETreeNode | null {
    return this.getPSModel5(
      S._1b2,
      this.getPSDETreeNodes(),
      objKey,
    ) as IPSDETreeNode;
  }

  get treeGridMode(): 0 | 1 | 2 {
    return this.M.treeGridMode;
  }

  hasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  get enableEdit(): boolean {
    return this.M.enableEdit != null ? this.M.enableEdit : false;
  }

  get enableRootSelect(): boolean {
    return this.M.enableRootSelect;
  }

  get outputIconDefault(): boolean {
    return this.M.outputIconDefault;
  }

  get rootVisible(): boolean {
    return this.M.rootVisible;
  }
  get cls(): string {
    return 'PSDETreeImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._1f || cls == S._264) return true;
    return super.instanceof(cls);
  }
}
